{extend name="public/baseLayuimini"}
{block name="title"}{/block}
{block name="css"}
<style>
    .layui-form-item .layui-input-company {width: auto;padding-right: 10px;line-height: 38px;}
</style>
{/block}
{block name="main"}
<div class="layuimini-container">
    <div class="layuimini-main">
        <form id="form" lay-filter="form" class="layui-form layuimini-form">
            <div class="layui-form-item">
                <label class="layui-form-label required">管理账号</label>
                <div class="layui-input-block">
                    <input type="text" name="user_name" lay-verify="required" lay-reqtext="管理账号不能为空" placeholder="请输入管理账号" class="layui-input">
                    <tip>填写自己管理账号的名称。</tip>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">昵称</label>
                <div class="layui-input-block">
                    <input type="text" name="nickname" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-block">
                    <input type="email" name="email"  placeholder="请输入邮箱" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="js"}
<script src="__LAYUIMINI__/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['form','miniTab'], function () {
        var form = layui.form,
            layer = layui.layer,
            miniTab = layui.miniTab,
            $ = layui.jquery;
        $.get('/admin/userSetting',res=>{
            console.log(res)
            form.val('form',{
                'user_name':res.user_name,
                'nickname':res.nickname,
                'email':res.email
            })
        })
        //监听提交
        form.on('submit(saveBtn)', function (data) {
            data = data.field
            $.post('/admin/userSetting',{user_name:data.user_name,nickname:data.nickname,email:data.email},res=>{
                layer.msg(res.msg,function(index){
                    if(res.code == 200){
                        layer.closeAll()
                        miniTab.deleteCurrentByIframe();
                    }
                })

            })
            return false;
        });

    });
</script>
{/block}